<style type="text/css">
#functionGroup label {
	height: 23px;
	line-height: 23px;
	white-space: nowrap;
}
#functionGroup input {
	width: auto;
	height: auto;
}
</style>
<div class="pageContent">
	<form class="pageForm required-validate">
		<div class="pageFormContent">
			<input type="hidden" name="navTabId" value="${navTabId!''}">
			<input type="hidden" name="id" value="${siteCode!''}">
			<fieldset>
				<dl>
					<dt>工厂编号：</dt>
					<dd>
						<input id="siteCode" name="siteCode" size="22" type="text" maxlength="20" class="required alphanumeric toUp"
							warn="工厂编号已存在" remote="${rc.getContextPath()}/manage/management/factory/validateSiteCode" />
					</dd>
				</dl>
				<dl>
					<dt>工厂描述：</dt>
					<dd>
						<input id="siteText" name="siteText" size="22" type="text" maxlength="60" class="required" />
					</dd>
				</dl>
				<dl>
					<dt>管理员密码：</dt>
					<dd>
						<input id="password" name="password" size="22" type="password" minlength="8" maxlength="20" class="required" />
					</dd>
				</dl>
				<dl>
					<dt>确认密码：</dt>
					<dd>
						<input name="repeatPwd" size="22" type="password" minlength="8" maxlength="20" equalto="#password" class="required" />
					</dd>
				</dl>
				<dl>
					<dt>数据恢复自：</dt>
					<dd>
						<select id="sourceSiteCode" class="required">
							<#if factories?? && factories?size &gt; 0>
								<#list factories as factory>
									<option value="${factory.siteCode!''}">${factory.siteText!''}</option>
								</#list>
							</#if>
						</select>
					</dd>
				</dl>
				<dl>
					<dt>&nbsp;</dt>
					<dd>
						<label>
							<input type="checkbox" id="lockFlag" value="1" />
							锁定
						</label>
					</dd>
				</dl>
				<dl class="nowrap">
					<dt>&nbsp;</dt>
					<dd>
						<div id="functionGroup" style="height: 200px; border: 1px solid #D9DFE5; width: 145px; overflow: auto;">
						<#if groups?? && groups?size &gt; 0>
							<#list groups as functionGroup>
								<label class="disableSelection" style="width: auto; min-width: 120px;">
									<input name="functionGroup" type="checkbox" value="${functionGroup.functionGroupCode!''}"
										<#if functionGroup.requiredFlag == 1>
										checked="true"
										disabled="true"
										</#if>
									/>
									${functionGroup.text!''}
								</label>
							</#list>
						</#if>
						</div>
					</dd>
				</dl>
			</fieldset>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button id="submit" >保存</button>
						</div>
					</div>
				</li>
				<li>
					<div class="buttonActiveGrey">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
$(function(){
	var $page = DWZ.context(), $form = $('form:first', $page), $submit = $('#submit', $form).on('click', function(){
		if (!$form.valid()) {
			return false;
		}
		var postData = {
			siteCode: $('#siteCode', $form).val().trim(),
			siteText: $('#siteText', $form).val().trim(),
			password: $('#password', $form).val().trim(),
			sourceSiteCode: $('#sourceSiteCode', $form).val().trim(),
			lockFlag: $('#lockFlag', $form)[0].checked ? 1 : 0
		};
		var functionGroups = new Array();
		$('[name=functionGroup]', $form).each(function(){
			if (this.checked) {
				functionGroups.push(this.value);
			}
		});
		postData.functionGroupCodes = functionGroups.join(",");
		DWZ.ajax({
			url: hostUrl + '/management/factory/saveFactory',
			data: postData,
			success: function() {
				$('#jGridForFactory', $page.data('_parent')).jGrid('loadData');
			},
			complete: function() {
				$.pdialog.close($page);
			}
		});
		return false;
	});
});
</script>